﻿using BCCommon;
using BCCommon.PaymentEnums;
using System.Collections.Generic;

namespace BCService.Common.Payment.Payment.WeixinPay
{
    /// <summary>
    /// 微信支付组件
    /// </summary>
    [NonInjection]
    public interface IWeiXinPayPlug
    {
        SourceAppType? AppType { get; set; }
        /// <summary>
        /// 将字典转换为URL参数(例如：a=1 b=2)
        /// </summary>
        /// <returns></returns>
        string FromDictionaryToUrlParameters();
        /// <summary>
        /// 将字典数据转换为string类型XML
        /// </summary>
        /// <returns></returns>
        string FromDictionaryToXml();
        /// <summary>
        /// 将string类型的XML转换为字典数据
        /// </summary>
        /// <param name="xml">xml数据</param>
        /// <returns></returns>
        SortedDictionary<string, object> FromXmlToDictionary(string xml);
        /// <summary>
        /// 生成时间戳
        /// </summary>
        /// <returns></returns>
        string GenerateTimeStamp();
        /// <summary>
        ///必选先构造过参数 获取字典
        /// </summary>
        /// <returns></returns>
        SortedDictionary<string, object> GetDictionary();
        /// <summary>
        /// Get请求
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        SortedDictionary<string, object> GetRequest(string url);
        /// <summary>
        /// 获取某个键值
        /// </summary>
        /// <param name="key">键</param>
        /// <returns></returns>
        object GetValue(string key);
        /// <summary>
        ///判断该键值是否已设置/存在
        /// </summary>
        /// <param name="key">键</param>
        /// <returns></returns>
        bool IsSet(string key);
        /// <summary>
        /// 生成签名
        /// </summary>
        /// <returns></returns>
        string MakeSign();
        /// <summary>
        /// 构造完参数后调用此方法
        /// </summary>
        /// <param name="url">访问地址</param>
        /// <param name="isCertRequest">证书访问请求</param>
        /// <returns></returns>
        SortedDictionary<string, object> PostRequest(string url, bool isCertRequest = false);
        /// <summary>
        /// 设置键值
        /// </summary>
        /// <param name="key">键</param>
        /// <param name="value">值</param>
        void SetValue(string key, object value);
        /// <summary>
        /// 验签
        /// </summary>
        /// <returns></returns>
        bool ValidateSign();
        /// <summary>
        /// 清理键值
        /// </summary>
        void ClearAllValue();
    }
}